home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-11-11 | 4.9 KB | 105 lines | [TEXT/MPS ] |
- ;
- ; File: SMResourceManagerPatch.a
- ;
- ; Written by: Steve Kiene
- ;
- ; Change History (most recent first):
- ;
- ; <1> 11/11/93 skk Initial version.
-
- **********************************************************************************************************
- * *
- * SuperMario Resource Manager patcher, written by Steve Kiene *
- * *
- * Background: With the advent of the SuperMario ROMs (AV class machines), Apple made a change to the *
- * Resource Manager to try and prevent damaged resource files. The change was to always flush a resource *
- * file whenever the end-of-file changed. This occurs as a result of the following traps: _UpdateResFile, *
- * _ChangedResource, _AddResource, _SetResInfo, and _RmveResource. *
- * This change does seem to help prevent damaged resource files, but it was a side-effect of causing *
- * many operations on resource files to slow down considerably. *
- * *
- * I have written a little piece of code to prevent the resource file from being flushed by the Resource *
- * Manager. While this will provide a speedup of some operations, it removes the safety that was added *
- * by Apple. If you crash while performing a resource operation, you are just as likely to suffer a *
- * damaged resource file as with pre-SuperMario ROMs. If safety is a concern, then this patch is not *
- * something for you to use. If speed is your main concern, then this is the patch for you. *
- * *
- * The patch looks back on the stack to see if the Resource Manager is the one who called _FlushFile. *
- * If so, it returns without calling _FlushFile. If someone else called, _FlushFile is called. *
- * It determines if the Resource Manager called by looking at the return address on the stack, which is *
- * stored at sp+28 (+28 because the trap dispatcher saves various registers on the stack before calling *
- * the trap. Once we have the return address, we look 10 bytes back and compare 12 bytes to see if it *
- * is the code of the subroutine that the Resource Manager uses to flush the cache. *
- * If someone has tail patched _FlushFile, this patch will not be effective. *
- * *
- * I have placed this code in the public domain. Anyone may use this as they wish. However, I take no *
- * responsibility and offer no warranties for this code. If it doesn't work for you, I'm sorry. If it *
- * works for you, then I hope you find it useful. *
- * *
- * Written by Steve Kiene, MindVision Software P.O. Box 81886 Lincoln, NE 68501 *
- * AppleLink, AOL: MINDVISION *
- * CIS: 70253,1437 *
- * *
- **********************************************************************************************************
-
-
- ; Build Commands
-
- ; asm RMgrPatch.a
- ; link RMgrPatch.a.o -rt INIT=1001 -rn -ra =resSysheap -t INIT -c MV15 ∂
- ; -o 'a:systemƒ:extensions:AV Resource Manager Tuner'
-
-
-
- include 'Traps.a'
- include 'SysEqu.a'
-
- MACHINE MC68040
-
- _CacheFlush OPWORD $a0bd
-
- MAIN PROC
-
- cmp.b #$04,CPUFlag ; is this an 040 (i.e. _might_ this patch be useful)
- blt.s @exit ; exit if not
-
- move.l a0,-(sp) ; resource handle is already in a0
- _DetachResource
-
- move #$a045,d0 ; _FlushFile trap
- _GetTrapAddress
- IMPORT MyAddr
- lea MyAddr+2,a1
- move.l a0,(a1) ; store original _FlushFile trap address
- _CacheFlush ; to write out the original trap address
-
- move #$a045,d0 ; _FlushFile trap
- IMPORT MyPatch
- lea MyPatch,a0
- _SetTrapAddress ; set _FlushFile to our code
-
- @exit
- rts
- ENDP
-
-
- MyPatch PROC EXPORT
-
- cmp.l #$009266ae,([28,sp],-10) ; look back at who called _FlushFile. See if we recognize
- bne.s @out ; the code. If these 12 bytes match, then we won't call
- cmp.l #$6100ff66,([28,sp],-6) ; the original _FlushFile.
- bne.s @out
- cmp.l #$a04560a2,([28,sp],-2)
- bne.s @out
-
- clr d0 ; return a result of noErr
- rts
-
- @out
- EXPORT MyAddr
- MyAddr
- jmp $80000000 ; call the original _FlushFile trap
- ENDP
-
- END
-